package com.heima.admin.controller;

import com.heima.model.admin.dtos.SensitiveDTO;
import com.heima.model.admin.pojos.AdSensitive;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.admin.service.AdSensitiveService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

/**
 * 敏感词过滤控制层
 */
@Api(value = "敏感词管理API", tags = "敏感词管理API")
@RestController
@RequestMapping("/api/v1/sensitive")
public class AdSensitiveController {
    @Autowired
    AdSensitiveService adSensitiveSrvice;

    @DeleteMapping("/del/{id}")
    public ResponseResult deleteSensitive(@PathVariable("id") Integer id) {
        return adSensitiveSrvice.deleteSensitive(id);
    }

    @PostMapping("/list")
    public ResponseResult querySensitive(@RequestBody SensitiveDTO sensitiveDTO) {
        return adSensitiveSrvice.querySensitive(sensitiveDTO);
    }

    /**
     * 保存
     * @param adSensitive
     * @return
     */
    @PostMapping("/save")
    public ResponseResult saveSensitive(@RequestBody AdSensitive adSensitive){
        return adSensitiveSrvice.saveSensitive(adSensitive);
    }

    /**
     * 修改
     * @param adSensitive
     * @return
     */
    @PostMapping("/update")
    public ResponseResult updateSensitive(@RequestBody AdSensitive adSensitive){
        return adSensitiveSrvice.updateSensitive(adSensitive);
    }

    @ApiOperation(value = "查询敏感词内容list")
    @PostMapping("/sensitives")
    public ResponseResult sensitives() {
        return adSensitiveSrvice.selectAllSensitives();
    }

}
